
import json
class  Send_req:

    def send_login(self,session,name,pwd):
        url = "http://192.168.1.238:90/login/verifyLogin"

        param = {
            "username": name,
            "password": pwd
        }
        #   请求接口并获取响应对象
        resp = session.get(url=url, params=param)

        resp.encoding = "utf-8"

        # 提取http协议状态码
        code = resp.status_code
        body = resp.text  # body --> str


        body = json.loads(body)  # str --> dict   dict --->  dumps

        return  {"code":code,"body":body}


    def  send_buy(self,session,id,uid,pwd):
        buy_url = "http://192.168.1.238:90/user/userBuyChangeMoney"

        buy_param = {
            "changeMoneyId":id,
            "userId":uid,
            "passWord":pwd
        }
        # get(key=value, params)   post(key=value,data)  post(json, json)
        buy_resp = session.post(url = buy_url,data = buy_param)

        buy_resp.encoding = "utf-8"
        code = buy_resp.status_code
        body = buy_resp.text  # body --> str

        # print(buy_resp.status_code,buy_resp.text)
        body = json.loads(body)  # str --> dict   dict --->  dumps

        return  {"code":code,"body":body}



